﻿<?xml version="1.0" encoding="utf-8" ?>
<Recipe Name="CreateVSCommand" xmlns="http://schemas.microsoft.com/pag/gax-core"
                               xmlns:xi="http://www.w3.org/2001/XInclude" Bound="false">
  <DocumentationLinks>
    <Link Kind="Documentation" Caption="VS Menus and Toolbars general" Url="ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.VSSDK.v80/dv_vsintegration/html/07b4ed90-dbbd-40df-b6c9-8395fd6f2ab6.htm" />
    <Link Kind="Documentation" Caption="Designing Command Table Configuration Files" Url="ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.VSSDK.v80/dv_vsintegration/html/1d9ae148-54a5-4a3c-9d85-a6932a9579a6.htm" />
    <Link Kind="Documentation" Caption="Common Menu Tasks" Url="ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.VSSDK.v80/dv_vsintegration/html/7b2be4b9-e3fe-4412-874f-ae72ebc84c4b.htm" />    
    <Link Kind="Documentation" Caption="How to: Create Basic Menus" Url="ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.VSSDK.v80/dv_vsintegration/html/62004fd9-7f99-4f00-8d01-1dde53e23dbb.htm" />
    <Link Kind="Documentation" Caption="How to: Create Context Menus" Url="ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.VSSDK.v80/dv_vsintegration/html/6012f22c-5a7a-46c4-acad-dbe82e0b7cb4.htm" />
  </DocumentationLinks>
  <xi:include href="../Common/CommonTypeAliases.xml"
				xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(/gax:Types)" />
  <Caption>VS Command</Caption>
  <Description>VS Command</Description>
  <HostData>
    <Icon ID="4206" />
    <CommandBar Menu="VSSDKAssistProjectCreate"/>
  </HostData>
  <Arguments>
    <xi:include href="../Common/CommonArguments.xml"
					  xpointer="xmlns(gax=http://schemas.microsoft.com/pag/gax-core) xpointer(/gax:Arguments/gax:Argument)" />
    <Argument Name="VSPackageProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.VisualStudio.CurrentlySelectedProjectValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="VSPackageProjectNamespace" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="$(VSPackageProject.Properties.Item('DefaultNamespace').Value.ToString())"
                     Stage="OnBeginRecipe">
      </ValueProvider>
    </Argument>
    <Argument Name="DestinationFolder" Required="true">
      <ValueProvider Type="Evaluator" 
                     Expression="Commands" 
                     Stage="OnBeginRecipe"/>
    </Argument>    
    <Argument Name="VSPackageCodeClass" Type="EnvDTE.CodeClass, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Required="true">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.VSPackageCodeClassValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="CommandName" Required="true"/>
    <Argument Name="CommandId" Required="true">
      <ValueProvider Type="VSSDKAssist.Recipes.CreateVSCommand.HexNumberValueProvider, VSSDKAssist" 
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="GroupName" Required="true">
      <ValueProvider Type="Evaluator" 
                     Expression="$(CommandName)Group"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="CommandName"/>
      </ValueProvider>
    </Argument>
    <Argument Name="GroupId" Required="true">
      <ValueProvider Type="VSSDKAssist.Recipes.CreateVSCommand.HexNumberValueProvider, VSSDKAssist" 
                     Stage="OnBeginRecipe"/>
    </Argument>    
    <Argument Name="CommandIdHFileName" Required="true">
      <ValueProvider Type="Evaluator" 
                     Expression="$(CommandName)Ids.h"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="CommandName"/>
      </ValueProvider>
    </Argument>
    <Argument Name="CommandGuidHFileName" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="$(CommandName)Guids.h"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="CommandName"/>
      </ValueProvider>
    </Argument>    
    <Argument Name="CommandIdCSFileName" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="$(CommandName)Constants.cs"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="CommandName"/>
      </ValueProvider>
    </Argument>
    <Argument Name="CommandCaption" Required="true"/>
    <Argument Name="CommandIdCSNamespace" Required="true">
      <ValueProvider Type="Evaluator" 
                     Expression="$(VSPackageProjectNamespace).$(DestinationFolder)"
                     Stage="OnBeginRecipe">
        <MonitorArgument Name="VSPackageProjectNamespace"/>
        <MonitorArgument Name="DestinationFolder"/>
      </ValueProvider>
    </Argument>
    <Argument Name="CtcProjectItem" Type="EnvDTE.ProjectItem, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Required="true">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.CtcProjectItemValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="DefaultParentGroup" Type="System.Boolean" Required="true">
      <ValueProvider Type="Evaluator"
                     Expression="true"
                     Stage="OnBeginRecipe" />
    </Argument>
    <Argument Name="ParentGroupGuidAlias" Required="true">
      <ValueProvider Type="Evaluator" 
                     Expression="guidSHLMainMenu"
                     Stage="OnBeginRecipe"/>
    </Argument>    
    <Argument Name="OtherParentGroupGuidAlias" Required="false">
      <ValueProvider Type="Evaluator"
               Expression="guid$(CommandName)ParentGroup"
               Stage="OnBeginRecipe">
        <MonitorArgument Name="CommandName"/>
      </ValueProvider>
    </Argument>
    <Argument Name="OtherParentGroupGuid" Required="false">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.Framework.EmptyGuidValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe" />
    </Argument>
    <Argument Name="ParentGroupIdAlias" Required="false"/>
    <Argument Name="OtherParentGroupIdAlias" Required="false">
      <ValueProvider Type="Evaluator"
               Expression="grpid$(CommandName)ParentGroup"
               Stage="OnBeginRecipe">
        <MonitorArgument Name="CommandName"/>
      </ValueProvider>
    </Argument>
    <Argument Name="OtherParentGroupId" Required="false">
      <ValueProvider Type="Evaluator"
                     Expression="0"
                     Stage="OnBeginRecipe" />
    </Argument>
    <Argument Name="CommandBitmapGuid" Type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.Framework.GuidValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="CommandGuid" Type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.Framework.GuidValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="BitmapResourceId" Required="true">
      <ValueProvider Type="VSSDKAssist.Assets.ValueProviders.Framework.RandomNumberValueProvider, VSSDKAssist.Assets"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="ResxProjectItem" Type="EnvDTE.ProjectItem, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Required="true">
      <ValueProvider 
        Type="VSSDKAssist.Recipes.Common.ValueProviders.VSPackageResxProjectItemValueProvider, VSSDKAssist"
        VSPackageCodeClassArgument="VSPackageCodeClass"/>
    </Argument>
    <Argument Name="BitmapDestinationFolder" Type="EnvDTE.ProjectItem, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Required="true">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.ResourcesFolderValueProvider, VSSDKAssist"
                     Stage="OnBeginRecipe"/>
    </Argument>
    <Argument Name="BitmapFileName" Required="true">
      <ValueProvider Type="VSSDKAssist.Recipes.Common.ValueProviders.EmptyBitmapValueProvider, VSSDKAssist"
                     ImageSize="Size16x16"
                     Stage="OnBeginRecipe"/>
    </Argument>
  </Arguments>
  <GatheringServiceData>
    <Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0">
      <Pages>
        <Page Type="VSSDKAssist.Recipes.CreateVSCommand.CreateVSCommandCP1, VSSDKAssist" 
          Height="200" Width="510">
          <Title>Specify command general properties</Title>
          <LinkTitle>Command general properties</LinkTitle>
        </Page>
        <Page Type="VSSDKAssist.Recipes.CreateVSCommand.CreateVSCommandCP2, VSSDKAssist"
          Height="200" Width="510">
          <Title>Specify command UI properties</Title>
          <LinkTitle>Command UI properties</LinkTitle>
        </Page>        
      </Pages>
    </Wizard>
  </GatheringServiceData>
  <Actions CoordinatorServiceType="VSSDKAssist.Recipes.Common.Coordinators.ExecutionProgressCoordinator, VSSDKAssist">
    <!--Create Folder-->
    <Action Name="GenerateDestinationFolder"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddProjectFolderAction, VSSDKAssist.Assets"
          StatusMessage="Creating destination folder"
          WriteMessageToOutputWindow="true">
      <Input Name="FolderName" RecipeArgument="DestinationFolder"/>
      <Output Name="FolderAdded" />
    </Action>
    <!--Create CommandIds.h-->
    <Action Name="GenerateCommandIdsH"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          Template="TT\VSCommand\CommandIdh.tt"
          StatusMessage="Creating CommandIds.h"
          WriteMessageToOutputWindow="true">
      <Input Name="GroupName" RecipeArgument="GroupName"/>
      <Input Name="CommandName" RecipeArgument="CommandName"/>
      <Input Name="GroupId" RecipeArgument="GroupId"/>
      <Input Name="CommandId" RecipeArgument="CommandId"/>
      <Input Name="BitmapResourceId" RecipeArgument="BitmapResourceId"/>
      <Input Name="DefaultParentGroup" RecipeArgument="DefaultParentGroup"/>
      <Input Name="OtherParentGroupIdAlias" RecipeArgument="OtherParentGroupIdAlias"/>
      <Input Name="OtherParentGroupId" RecipeArgument="OtherParentGroupId"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddCommandIdsHContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateCommandIdsH.Content" />
      <Input Name="TargetFileName" RecipeArgument="CommandIdHFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateDestinationFolder.FolderAdded" />
      <Output Name="ProjectItem" />
    </Action>
    <!--Create CommandGuids.h-->
    <Action Name="GenerateCommandGuidsH"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          Template="TT\VSCommand\CommandGuidh.tt"
          StatusMessage="Creating CommandGuids.h"
          WriteMessageToOutputWindow="true">
      <Input Name="CommandName" RecipeArgument="CommandName"/>
      <Input Name="CommandGuid" RecipeArgument="CommandGuid"/>
      <Input Name="CommandBitmapGuid" RecipeArgument="CommandBitmapGuid"/>
      <Input Name="DefaultParentGroup" RecipeArgument="DefaultParentGroup"/>
      <Input Name="OtherParentGroupGuidAlias" RecipeArgument="OtherParentGroupGuidAlias"/>
      <Input Name="OtherParentGroupGuid" RecipeArgument="OtherParentGroupGuid"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddCommandGuidsHContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateCommandGuidsH.Content" />
      <Input Name="TargetFileName" RecipeArgument="CommandGuidHFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateDestinationFolder.FolderAdded" />
      <Output Name="ProjectItem" />
    </Action>    
    <!--Create CommandConstants.cs-->
    <Action Name="GenerateCommandCS"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          Template="TT\VSCommand\CommandIdcs.tt"
          StatusMessage="Creating CommandConstants.cs"
          WriteMessageToOutputWindow="true">
      <Input Name="CommandIdCSNamespace" RecipeArgument="CommandIdCSNamespace"/>
      <Input Name="CommandName" RecipeArgument="CommandName"/>
      <Input Name="CommandId" RecipeArgument="CommandId"/>
      <Input Name="CommandGuid" RecipeArgument="CommandGuid"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddCommandCSContent"
          Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromStringToProjectItemAction, VSSDKAssist.Assets"
          Open="true">
      <Input Name="Content" ActionOutput="GenerateCommandCS.Content" />
      <Input Name="TargetFileName" RecipeArgument="CommandIdCSFileName"/>
      <Input Name="InputProjectItem" ActionOutput="GenerateDestinationFolder.FolderAdded" />
      <Output Name="ProjectItem" />
    </Action>
    <!--Update ctc file-->
    <Action Name="InsertCommandIdHIncludeDirective" Type="VSSDKAssist.Assets.Actions.VisualStudio.InsertTextAction, VSSDKAssist.Assets"
        SearchExpression="\#include" 
        TextToInsert="#include &quot;..\$(DestinationFolder)\$(CommandIdHFileName)&quot;"
        InsertPosition="After"
        StatusMessage="Updating ctc file"
        WriteMessageToOutputWindow="true">
      <Input Name="ProjectItem" RecipeArgument="CtcProjectItem" />
    </Action>
    <Action Name="InsertCommandGuidHIncludeDirective" Type="VSSDKAssist.Assets.Actions.VisualStudio.InsertTextAction, VSSDKAssist.Assets"
        SearchExpression="\#include"
        TextToInsert="#include &quot;..\$(DestinationFolder)\$(CommandGuidHFileName)&quot;"
        InsertPosition="After">
      <Input Name="ProjectItem" RecipeArgument="CtcProjectItem" />
    </Action>    
    <Action Name="GetGroupDefinition" Type="VSSDKAssist.Recipes.CreateVSCommand.CreateGroupDefinitionAction, VSSDKAssist">
      <Input Name="CommandName" RecipeArgument="CommandName"/>
      <Input Name="GroupName" RecipeArgument="GroupName" />
      <Input Name="DefaultParentGroup" RecipeArgument="DefaultParentGroup"/>
      <Input Name="ParentGroupGuidAlias" RecipeArgument="ParentGroupGuidAlias" />
      <Input Name="ParentGroupIdAlias" RecipeArgument="ParentGroupIdAlias" />
      <Input Name="OtherParentGroupGuidAlias" RecipeArgument="OtherParentGroupGuidAlias"/>
      <Input Name="OtherParentGroupIdAlias" RecipeArgument="OtherParentGroupIdAlias"/>
      <Output Name="GroupDefinition" />
    </Action>
    <Action Name="InsertNewGroupDefinition" Type="VSSDKAssist.Assets.Actions.VisualStudio.InsertTextAction, VSSDKAssist.Assets"
        SearchExpression="NEWGROUPS_END"
        InsertPosition="Before">
      <Input Name="TextToInsert" ActionOutput="GetGroupDefinition.GroupDefinition" />
      <Input Name="ProjectItem" RecipeArgument="CtcProjectItem" />
    </Action>
    <Action Name="GetCommandDefinition" Type="VSSDKAssist.Recipes.CreateVSCommand.CreateCommandDefinitionAction, VSSDKAssist">
      <Input Name="GroupName" RecipeArgument="GroupName" />
      <Input Name="CommandName" RecipeArgument="CommandName" />
      <Input Name="CommandCaption" RecipeArgument="CommandCaption" />
      <Output Name="CommandDefinition" />
    </Action>
    <Action Name="InsertButtonDefinition" Type="VSSDKAssist.Assets.Actions.VisualStudio.InsertTextAction, VSSDKAssist.Assets"
        SearchExpression="BUTTONS_END"
        InsertPosition="Before">
      <Input Name="TextToInsert" ActionOutput="GetCommandDefinition.CommandDefinition" />
      <Input Name="ProjectItem" RecipeArgument="CtcProjectItem" />
    </Action>
    <Action Name="GetBitmapDefinition" Type="VSSDKAssist.Recipes.CreateVSCommand.CreateBitmapDefinitionAction, VSSDKAssist">
      <Input Name="CommandName" RecipeArgument="CommandName" />
      <Output Name="BitmapDefinition" />
    </Action>
    <Action Name="InsertBitmapDefinition" Type="VSSDKAssist.Assets.Actions.VisualStudio.InsertTextAction, VSSDKAssist.Assets"
        SearchExpression="BITMAPS_END"
        InsertPosition="Before">
      <Input Name="TextToInsert" ActionOutput="GetBitmapDefinition.BitmapDefinition" />
      <Input Name="ProjectItem" RecipeArgument="CtcProjectItem" />
    </Action>    
    <!--Add Bitmap File-->
    <Action Name="AddBitmapFile" Type="VSSDKAssist.Assets.Actions.VisualStudio.AddItemFromFileToProjectItemAction, VSSDKAssist.Assets"
            Open="false"
            StatusMessage="Adding bitmap file"
            WriteMessageToOutputWindow="true">
      <Input Name="SourceFileName" RecipeArgument="BitmapFileName"/>
      <Input Name="InputProjectItem" RecipeArgument="BitmapDestinationFolder"/>
      <Output Name="ProjectItem" />
    </Action>
    <!-- Update Resx -->
    <Action Name="UpdateResx" Type="VSSDKAssist.Recipes.Common.Actions.AppendBitmapResxEntryAction, VSSDKAssist"
            StatusMessage="Updating resource file"
            WriteMessageToOutputWindow="true">
      <Input Name="ResxProjectItem" RecipeArgument="ResxProjectItem"/>
      <Input Name="BitmapProjectItem" ActionOutput="AddBitmapFile.ProjectItem"/>
      <Input Name="BitmapResourceId" RecipeArgument="BitmapResourceId"/>
    </Action>
    <!--Add Command Handler Call-->
    <Action Name="GenerateCommandHandlerCallContent"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          Template="TT\VSCommand\CommandHandlerCall.tt">
      <Input Name="CommandName" RecipeArgument="CommandName"/>
      <Output Name="Content" />
    </Action>
    <Action Name="AddInitializeMethod" Type="VSSDKAssist.Recipes.Common.Actions.AddVSPackageInitializeFunctionAction, VSSDKAssist">
      <Input Name="CodeClass" RecipeArgument="VSPackageCodeClass" />
      <Output Name="CodeFunction" />
    </Action>
    <Action Name="InsertServiceInitialize" Type="VSSDKAssist.Assets.Actions.VisualStudio.InsertTextToCodeElementAction, VSSDKAssist.Assets">
      <Input Name="TextToInsert" ActionOutput="GenerateCommandHandlerCallContent.Content" />
      <Input Name="CodeElement" ActionOutput="AddInitializeMethod.CodeFunction" />
    </Action>    
    <!--Add Command Handler-->
    <Action Name="GenerateCommandHandler"
          Type="Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates.TextTemplateAction, Microsoft.Practices.RecipeFramework.VisualStudio.Library"
          Template="TT\VSCommand\CommandHandler.tt"
          StatusMessage="Adding command registration information"
          WriteMessageToOutputWindow="true">
      <Input Name="CommandName" RecipeArgument="CommandName"/>
      <Input Name="CommandIdCSNamespace" RecipeArgument="CommandIdCSNamespace"/>
      <Output Name="Content" />
    </Action>
    <Action Name="InsertCommandHandler" Type="VSSDKAssist.Assets.Actions.VisualStudio.InsertTextToCodeElementAction, VSSDKAssist.Assets">
      <Input Name="TextToInsert" ActionOutput="GenerateCommandHandler.Content" />
      <Input Name="CodeElement" RecipeArgument="VSPackageCodeClass" />
    </Action>    
  </Actions>
</Recipe>